define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'broker/sellershouse/index' + location.search,
                    add_url: 'broker/sellershouse/add',
                    edit_url: 'broker/sellershouse/edit',
                    del_url: 'broker/sellershouse/del',
                    multi_url: 'broker/sellershouse/multi',
                    import_url: 'broker/sellershouse/import',
                    table: 'sellers_house',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'sales_representative', title: __('Sales_representative'), operate: 'LIKE'},
                        {field: 'date_of_visit', title: __('Date_of_visit'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'sex_data', title: __('Sex_data'), searchList: {"1":__('Sex_data 1'),"2":__('Sex_data 2')}, formatter: Table.api.formatter.normal},
                        {field: 'contact', title: __('Contact'), operate: 'LIKE'},
                        {field: 'collection_shijian', title: __('Collection_shijian'), operate: 'LIKE'},
                        {field: 'house_area', title: __('House_area'), operate: 'LIKE'},
                        {field: 'house_type', title: __('House_type'), operate: 'LIKE'},
                        {field: 'decoration_standards_data', title: __('Decoration_standards_data'), searchList: {"1":__('Decoration_standards_data 1'),"2":__('Decoration_standards_data 2'),"3":__('Decoration_standards_data 3'),"4":__('Decoration_standards_data 4')}, formatter: Table.api.formatter.normal},
                        {field: 'mortgage_status_data', title: __('Mortgage_status_data'), searchList: {"1":__('Mortgage_status_data 1'),"2":__('Mortgage_status_data 2'),"3":__('Mortgage_status_data 3'),"4":__('Mortgage_status_data 4')}, formatter: Table.api.formatter.normal},
                        {field: 'residential_status_data', title: __('Residential_status_data'), searchList: {"1":__('Residential_status_data 1'),"2":__('Residential_status_data 2'),"3":__('Residential_status_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'sales_cycle_data', title: __('Sales_cycle_data'), searchList: {"1":__('Sales_cycle_data 1'),"2":__('Sales_cycle_data 2'),"3":__('Sales_cycle_data 3'),"4":__('Sales_cycle_data 4')}, formatter: Table.api.formatter.normal},
                        {field: 'certificate_processing_time_data', title: __('Certificate_processing_time_data'), searchList: {"1":__('Certificate_processing_time_data 1'),"2":__('Certificate_processing_time_data 2'),"3":__('Certificate_processing_time_data 3'),"4":__('Certificate_processing_time_data 4')}, formatter: Table.api.formatter.normal},
                        {field: 'pay_method_data', title: __('Pay_method_data'), searchList: {"1":__('Pay_method_data 1'),"2":__('Pay_method_data 2'),"3":__('Pay_method_data 3')}, formatter: Table.api.formatter.normal},
                        {field: 'number_of_properties', title: __('Number_of_properties'), searchList: {"1":__('Number_of_properties 1'),"2":__('Number_of_properties 2'),"3":__('Number_of_properties 3'),"4":__('Number_of_properties 4')}, formatter: Table.api.formatter.normal},
                        {field: 'price', title: __('Price'), operate: 'LIKE'},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
